﻿Imports SignalR.Hubs
Imports Tajan.Monitoring.Entities.Client
Imports Tajan.Monitoring.Service

<HubName("monitoringtHub")>
Public Class MonitoringHub
    Inherits Hub
    Implements IDisconnect
    Implements IConnected

    Public Function sendPageViewInfo(pageViewInfo As PageViewInfo) As Long
        Dim manager As New Manager
        manager.AddPageView(pageViewInfo)
        Return pageViewInfo.PageViewId
    End Function

    Public Function Disconnect() As Threading.Tasks.Task Implements IDisconnect.Disconnect
        Dim connectionId = Context.ConnectionId
        Dim manager As New Manager
        manager.Disconnected(connectionId)
        Return Clients.leave(connectionId, DateTime.Now.ToString())
    End Function

    Public Function Connect() As Threading.Tasks.Task Implements IConnected.Connect
        Return Clients.joined(Context.ConnectionId, DateTime.Now.ToString())
    End Function

    Public Function Reconnect(groups As IEnumerable(Of String)) As Threading.Tasks.Task Implements IConnected.Reconnect
        Return Clients.rejoined(Context.ConnectionId, DateTime.Now.ToString())
    End Function

End Class
